package com.litong.litongjiaoyu.service.impl;

import com.litong.litongjiaoyu.dao.TeacherDao;
import com.litong.litongjiaoyu.entity.TeacherUserinfo;
import com.litong.litongjiaoyu.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @ClassName TeacherServiceImpl
 * @Description TODO
 * @Author jingz
 * @Date 2019/7/18 23:53
 * @Version 1.0
 **/
@Service
public class TeacherServiceImpl implements TeacherService {

    @Autowired
    private TeacherDao teacherDao;

    /**
     * @param teacherUserinfo
     * @return int
     * @Author jingz
     * @Description 添加老师方法
     * @Date 23:51 2019/7/18
     * @Param []
     */
    @Override
    public int insertTeacher(TeacherUserinfo teacherUserinfo) {
        return teacherDao.insertTeacher(teacherUserinfo);
    }


    /**
     * 更新老师信息
     *
     * @param teacherUserinfo
     * @return
     */
    @Transactional
    @Override
    public int upadteTeacherInfo(TeacherUserinfo teacherUserinfo) {
        return teacherDao.upadteTeacherInfo(teacherUserinfo);
    }

    /**
     * 删除老师信息
     *
     * @param phone
     * @return
     */
    @Transactional
    @Override
    public int remove(int id, String phone) {
        return teacherDao.remove(id,phone);
    }

    /**
     * 获取老师列表
     *
     * @return
     */
    @Override
    public List<TeacherUserinfo> query() {
        return teacherDao.query();
    }

    /**
     * 查询某个老师全部信息
     *
     * @param id
     * @return
     */
    @Override
    public TeacherUserinfo selectInfo(int id) {
        return teacherDao.selectInfo(id);
    }

    /**
     * 登录时获取所有信息
     *
     * @param openid
     * @return
     */
    @Override
    public TeacherUserinfo selectTeacherInfo(String openid) {
        return teacherDao.selectTeacherInfo(openid);
    }

    /**
     * @param classname
     * @return java.util.List<java.lang.String>
     * @Author jingz
     * @Description 获取老师所教班级取得该班级中所有学生的openid
     * @Date 10:53 2019/7/28
     * @Param [openid]
     */
    @Override
    public List<String> getStudentOpenidByclass(String classname) {
        return null;
    }

    /**
     * 批量删除
     *
     * @param userIds
     * @return
     */
    @Transactional
    @Override
    public int batchRemove(String[] userIds) {
        return teacherDao.batchRemove(userIds);
    }

    /**
     * 批量修改职位信息
     *
     * @param maps
     * @return int
     */
    @Transactional
    @Override
    public int batchModifyPosition(Map<Integer,Integer> maps) {
        return teacherDao.batchModifyPosition(maps);
    }

    /**
     * 模糊搜索
     *
     * @param text
     * @return
     */
    @Override
    public List<TeacherUserinfo> search(String text) {
        return teacherDao.search(text);
    }
}
